package com.example.springbootshiro.controller;

import com.example.springbootshiro.response.CommonReturnData;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by YangGang on 2021/12/15 14:08。
 */
@Slf4j
@RestController
@RequestMapping("/task")
public class TaskController {

    @GetMapping("/getTaskInfo")
    public Object getTaskInfo(String name) {
        log.debug("getTaskInfo >>> " + name);
        Subject subject = SecurityUtils.getSubject();
        return CommonReturnData.success(subject.getPrincipal() + "," + name);
    }

    @PostMapping("/add")
    public Object add(String name) {
        log.debug("add >>> " + name);
        log.debug("add >>> 阿斯顿花生酱");
        Subject subject = SecurityUtils.getSubject();
        return CommonReturnData.success(subject.getPrincipal() + "," + name);
    }


}
